<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.neuedu.entity.User" %>
<%--
  Created by IntelliJ IDEA.
  User: root
  Date: 2020/12/14
  Time: 8:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1>EL中的基础操作符</h1>
加减乘除
$ {1+2} : ${1+2}<br/>
$ {1-2} : ${1-2}<br/>
$ {1*2} : ${1*2}<br/>
$ {1/2} : ${1/2}<br/>
$ {1.0 div 2.0} : ${1.0 div 2.0}<br/>


$ {1%2} : ${1%2}<br/>
$ {1 mod 2} : ${1 mod 2}<br/>
$ {1 == 2} : ${1 == 2}<br/>
$ {1 eq 2} : ${1 eq 2}<br/>
$ {1 != 2} : ${1 != 2}<br/>
$ {1 != 2} : ${1 != 2}<br/>
$ {1 > 2} : ${1 > 2}<br/>


$ {true && false} : ${true && false}<br/>
$ {true or false} : ${true or false}<br/>
$ {!true } : ${! true }<br/>


<%
    //从作用域中获取值
    request.setAttribute("name", "jshand");
%>
$ {name}: ${name}  <br/>
$ {empty name}: ${empty  name} <br/>
$ {empty age}: ${empty  age} <br/>
<hr/>

<%
    request.setAttribute("arr", new String[]{"星期一", "星期二", "星期三"});
%>

<h3>数组的访问</h3>
$ {arr[0]} : ${arr[0]} <br/>
$ {arr[1]} : ${arr[1]} <br/>
$ {arr[2]} : ${arr[2]} <br/>
<hr/>

<%
    List list = new ArrayList();
    list.add("张飞");
    list.add("刘备");
    list.add("关羽");
    request.setAttribute("list", list);
%>
<h3>集合的访问</h3>
$ {list[0]} : ${list[0]} <br/>
$ {list[1]} : ${list[1]} <br/>
$ {list[2]} : ${list[2]} <br/>
<hr/>

<%

    Map userMap  = new HashMap();
    userMap.put("id",1);
    userMap.put("name","jshand");
    request.setAttribute("userMap", userMap);
%>

$ {userMap.id}:  ${userMap.id}<br/>
$ {userMap.name}:  ${userMap.name}<br/>
$ {userMap['name']}:  ${userMap['name']}<br/>



<hr/>

<%

    User user = new User();
    user.setUserid(999);
    user.setUsername("admin");
    user.setPassword("123456");
    request.setAttribute("user",user);
%>

<h3>JavaBean的访问</h3>
$ {user.userid}:  ${user.userid}<br/>
$ {user.username}:  ${user.username}<br/>
$ {user.password}:  ${user.password}<br/>
$ {user['username']}:  ${user['username']}<br/>


<h3>()改变运算符优先级</h3>





$ {(1+2)*3} : ${(1+2)*3}


</body>
</html>
